﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Helpers;

namespace Helpers.Conditions
{
    public class NotCondition<T> : BaseCondition<T>
    {
        protected BaseCondition<T> InnerCondition { get; set; }

        public NotCondition(BaseCondition<T> condition)
        {
            if (condition != null)
                InnerCondition = condition;
        }

        public void Set(BaseCondition<T> condition)
        {
            InnerCondition = condition;
        }

        public override bool IsAccepted(T element)
        {
            if (InnerCondition == null)
                return false;

            bool result = !InnerCondition.IsAccepted(element);
            
            return result;
        }
    }
}
